﻿using System;
using System.Text;

namespace Script_Text_Editor_WPF_Edition.Library
{
    class PureTextWrapper : ILibrary
    {
        /// <summary>
        /// 获取当前类型的内部编号
        /// </summary>
        public static int Index
        {
            get { return 0; }
        }

        #region Interface methods

        byte[] contents;

        public string GetLibraryInfo()
        {
            return "纯文本";
        }

        public string GetSupportExtensions()
        {
            return "*.*|*.*";
        }

        public string GetStringBreakLineChar()
        {
            return Environment.NewLine;
        }

        public bool GetCanMakeNewLine()
        {
            return false;
        }

        public string GetNewLineBreakChar()
        {
            return @"\n";
        }

        public string GetStringCollection(byte[] file)
        {
            contents = file;

            return Encoding.Default.GetString(contents);
        }

        public byte[] SetStringCollection(string file)
        {
            contents = Encoding.Default.GetBytes(file);

            return contents;
        }

        #endregion Interface methods
    }
}